import React, { Component } from 'react'

export default function Fn() {
    let flag = true
    let list = [{name:'zs',age:15},{name:'ls',age:20}]
    let titleFlag = 2
    function getTitle(){
        if(titleFlag==0){
            return <div>这是0展示的内容</div>
        }else if(titleFlag==1){
            return <div>这是1展示的内容</div>
        }else if(titleFlag==2){
            return <div>这是2展示的内容</div>
        }
    }
    //事件参数
    let handle =(e)=>{
        console.log(e);
        
    }
    //传递自定义参数
    let handle2 = (e,name)=>{
        console.log(e,name,'name');
        
    }
    return <>
        <div>列表渲染</div>
        <ul>
            {list.map((item,index)=><li key={index}>{item.name}{item.age}</li>)}
            
        </ul>
        {flag && '只是显示的内容'}
        {flag ? <div>loading......</div> : '没有展示内容' }
        {getTitle()}
        <button onClick={handle}>按钮</button>
        <button onClick={(e)=>handle2(e,'我的名字')}>按钮2</button>
    </>
}